from sqlalchemy import Column, Integer, ForeignKey, String, Float, JSON

from models import Base


class TestDetail(Base):
    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    name = Column(String(100), comment="测试用例名称")
    requestMethod = Column(String(10), comment="请求方法")
    url = Column(String(1000), comment="请求地址")
    headers = Column(JSON, comment="请求头")
    cookies = Column(JSON, comment="请求Cookie")
    requestParams = Column(JSON, comment="请求参数")
    checkHttpCode = Column(String(10), comment="HTTP状态码校验")
    httpCode = Column(Integer, comment="响应实际状态码")
    checkResponseData = Column(JSON, comment="JSON正则校验")
    testResult = Column(JSON, comment="测试结果")
    testConclusion = Column(String(100), comment="测试结论")
    checkResponseTime = Column(Float(10), comment="接口耗时校验")
    responseTime = Column(Float(10), comment="接口耗时")

    test_report_id = Column(Integer, ForeignKey('testreport.id', ondelete="CASCADE"), comment="测试报告ID")